package com.finance.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.common.vo.PageVo;
import com.finance.dao.YhUserMapper;
import com.finance.entity.YhUser;

@Service("YhUserService")
public class YhUserService {

	@Resource(name = "YhUserMapper")
	private YhUserMapper yhUserMapper;

	/**
	 * 按id删除用户
	 * 
	 * @param yhUserId
	 */
	public void deleteByPrimaryKey(String yhUserId) {
		yhUserMapper.deleteByPrimaryKey(yhUserId);
	}

	/**
	 * 添加用户
	 * 
	 * @param record
	 */
	public void insert(YhUser record) {
		yhUserMapper.insert(record);
	}

	/**
	 * 按ID查询
	 * 
	 * @param yhUserId
	 * @return
	 */
	public YhUser selectByPrimaryKey(String yhUserId) {
		return yhUserMapper.selectByPrimaryKey(yhUserId);
	}

	/**
	 * 选择性更新
	 * 
	 * @param record
	 */
	public void updateByPrimaryKeySelective(YhUser record) {
		yhUserMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 更新
	 * 
	 * @param record
	 */
	public void updateByPrimaryKey(YhUser record) {
		yhUserMapper.updateByPrimaryKey(record);
	}

	/**
	 * 分页+搜索
	 * 
	 * @param search
	 * @param pageNum
	 * @return
	 */
	public PageVo<YhUser> findPageBySearch(YhUser search, int pageNum) {
		PageVo<YhUser> page = new PageVo<YhUser>(pageNum);
		page.setRows(3);
		List<YhUser> list = yhUserMapper.findByPageBySearch(search,
				page.getOffset(), page.getRows());
		int count = yhUserMapper.countPageBySearch(search);
		page.setCount(count);
		page.setList(list);
		return page;
	}

	/**
	 * 通过身份证查询
	 */
	public YhUser findByIdCard(String yhUserIdcard) {
		return yhUserMapper.findByIdCard(yhUserIdcard);
	}
	
	/**
	 * 修改贷款状态
	 */
	public void updateLoanSate(YhUser yhUser){
		yhUserMapper.updateLoanState(yhUser);
	}
	
	/**
	 * 查询正常贷款人数
	 */
	public int findByzc(Integer loanState){
		return yhUserMapper.findByzc(loanState);
	}
	
	/**
	 * 查询完成贷款人数
	 */
	public int findBywc(Integer loanState){
		return yhUserMapper.findBywc(loanState);
	}
	
	/**
	 * 查询逾期人数
	 */
	public int findByYuQi(Integer loanState){
		return yhUserMapper.findByYuQi(loanState);
	}
	

}
